﻿<Application
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"       
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:services="clr-namespace:WPControla.Client.Services" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" 
    x:Class="WPControla.Client.App"
    >

    <!--Application Resources-->
    <Application.Resources>
        <services:ViewModelLocatorService x:Key="locator"/>

        <SolidColorBrush Color="#FF25A0DB" x:Key="BackgroundColor"></SolidColorBrush>
        
        <ControlTemplate x:Key="playButton" TargetType="Button">
            <Grid>
                <Rectangle Fill="{StaticResource BackgroundColor}" Width="48"
                           Height="48"></Rectangle>
                <Image Height="48" Source="images/play.png" Stretch="Fill" Width="48">
                </Image>
            </Grid>
        </ControlTemplate>

        <DataTemplate x:Key="PodcastTemplate">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="58"></ColumnDefinition>
                    <ColumnDefinition Width="*"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="50"></RowDefinition>
                    <RowDefinition Height="60"></RowDefinition>
                </Grid.RowDefinitions>

                <Button Grid.Column="0" Grid.Row="0" Width="48" Height="48"
                        VerticalAlignment="Center" Template="{StaticResource playButton}"
                        HorizontalAlignment="Left" Margin="0"
                        CommandParameter="{Binding}" Command="{Binding ElementName=lstChapters, Path=DataContext.PreviewAudioCommand}">
                </Button>

                <TextBlock Text="{Binding Title}" Foreground="LightBlue"
                                           FontSize="{StaticResource PhoneFontSizeLarge}"
                                           Grid.Row="0" Grid.Column="1" VerticalAlignment="Center"></TextBlock>
                <TextBlock Text="{Binding Subtitle}" Foreground="White"
                                           FontSize="{StaticResource PhoneFontSizeNormal}"
                                           TextWrapping="Wrap" TextTrimming="WordEllipsis"
                                           Height="60"
                                           Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2"></TextBlock>
            </Grid>
        </DataTemplate>

        <DataTemplate x:Key="ArticlesTemplate">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="48"></ColumnDefinition>
                    <ColumnDefinition Width="*"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="48"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                </Grid.RowDefinitions>

                <Image Height="48" Source="images/Articles.png" Stretch="Fill" Width="48"
                                       Grid.Row="0" Grid.Column="0"/>

                <TextBlock Text="{Binding Title}" Foreground="LightBlue"
                           FontSize="{StaticResource PhoneFontSizeLarge}"
                           TextWrapping="Wrap"
                           Grid.Row="0" Grid.Column="1"></TextBlock>
            </Grid>
        </DataTemplate>

        <DataTemplate x:Key="TwitterTemplate">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="48"></ColumnDefinition>
                    <ColumnDefinition Width="*"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="48"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                </Grid.RowDefinitions>

                <Image Height="48" Source="images/Twitter.png" Stretch="Fill" Width="48"
                                       Grid.Row="0" Grid.Column="0"/>

                <TextBlock Text="{Binding DateTime}" Foreground="LightBlue"
                                           FontSize="{StaticResource PhoneFontSizeLarge}"
                                           Grid.Row="0" Grid.Column="1"></TextBlock>
                <TextBlock Text="{Binding Content}" Foreground="White"
                                           FontSize="{StaticResource PhoneFontSizeNormal}"
                                           TextWrapping="Wrap"
                                           Grid.Row="1" Grid.Column="1"></TextBlock>
            </Grid>
        </DataTemplate>
    </Application.Resources>

    <Application.ApplicationLifetimeObjects>
        <!--Required object that handles lifetime events for the application-->
        <shell:PhoneApplicationService 
            Launching="Application_Launching" Closing="Application_Closing" 
            Activated="Application_Activated" Deactivated="Application_Deactivated"/>
    </Application.ApplicationLifetimeObjects>

</Application>